#!/bin/bash

#Please change the following 5 variables

#The path to put CGIs on your web server
#NOTE: You need to have write permission, when executing the script
CGI_PATH=/usr/lib/cgi-bin

#The WWW ROOT path
#NOTE: You need to have write permission, when executing the script
HTML_PATH=/var/www

#The path where BACA can be found
#Most probably you won't need to change this as it gets the current
#directory. If that is the correct option, don't change it
BACA_DIR=`pwd`

#NOTE: If you change the location of the software you will need to rerun
#install.sh


#Email address of de administrator
#please dont forget to include 3 \ before the @, ie \\\@
SENDER=somebody\\\@acme.com

#The URL where BACA will be available
TOPURL=http://your.host.edu/baca

#There is no need to change anything below



echo Instalation directories
echo CGI  path is $CGI_PATH
echo HTML path is $HTML_PATH
echo BACA path is $BACA_DIR
echo

echo Preparing scripts
echo
perl -pi -e "s;BACADIR=.*$;BACADIR=$BACA_DIR;" do_all.sh
perl -pi -e "s;SENDER=.*$;SENDER=$SENDER;" do_all.sh
perl -pi -e "s;TOPURL=.*$;TOPURL=$TOPURL;" do_all.sh


perl -pi -e "s%job_dir = '.*$%job_dir = '$HTML_PATH/baca/jobs';%" cgi/geno.pl
perl -pi -e "s%bin = '.*$%bin = '$BACA_DIR/do_all.sh';%" cgi/geno.pl
perl -pi -e "s%web_url = '.*$%web_url = '/baca/jobs';%" cgi/geno.pl


echo Creating directories and copying files
echo "  you can ignore directoy creation errors, if those already exist"
mkdir $HTML_PATH/baca
mkdir $HTML_PATH/baca/jobs
chmod a+rwx $HTML_PATH/baca/jobs
cp html/*html $HTML_PATH/baca
cp cgi/geno.pl $CGI_PATH

